/**
Audio.hpp
Title: Binge Audio Header File
Descr: Audio Class

Copyright (c) 2010, Brant Ryan Anderson
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the <ORGANIZATION> nor the names of its contributors
      may be used to endorse or promote products derived from this software
      without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/

#ifndef BINGE_AUDIO_HPP
#define BINGE_AUDIO_HPP

#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <SFML/Audio.hpp>

namespace binge
{

class Music
{
public:
	Music(void) {  };
	virtual ~Music(void) {  };

	std::string getName() { return name; }
	void setName(std::string value) { name = value; }

	std::string getFilename() { return filename; }
	void setFilename(std::string value) { filename = value; }

private:
	std::string name;
	std::string filename;
};

class Effect
{
public:
	sf::SoundBuffer sample;
	sf::Sound sound;

	Effect(void) {  }
	virtual ~Effect(void) {  }

	std::string getName() { return name; }
	void setName(std::string value) { name = value; }

private:
	std::string name;
};

class Audio
{
private:
	sf::Music musicSample;

	typedef std::vector<Music*> MusicList;
	typedef std::vector<Music*>::iterator musicIter;
	MusicList musicList;

	unsigned int songNum;
	bool musicPaused;
	typedef std::vector<Effect*> EffectList;
	typedef std::vector<Effect*>::iterator effectIter;
	EffectList effectList;

public:
	Audio(void);
	virtual ~Audio(void);

	bool playlist;
	bool disabled;

	bool Init(void);
	void Close(void);

	Effect* Effect_Find(std::string name);
	bool Effect_Load(std::string filename, std::string name);
	bool Effect_Play(std::string name);

	Music* Music_Find(std::string name);
	bool Music_Load(std::string filename, std::string name);
	bool Music_Play(std::string name); // Loops sample forever.
	bool Music_List_Play(void); // Plays each song once and loops the playlist.
	bool Music_List_Next(void);
	bool Music_List_Prev(void);
	void Music_Pause(void);
	void Music_Resume(void);
	void Music_Stop(void);
	bool Music_isPlaying(void);
	bool Music_isPaused(void) { return musicPaused; }
};

} // namespace

#endif
